<template>
	<view class="main">
		<view class="row">
			<view class="title">出错点</view>
			<textarea class="textArea" placeholder="这里是问题内容" maxlength="-1" v-model="form.wrong_text"></textarea>
		</view>
		<view class="row">
			<view class="title">具体解释</view>
			<textarea class="textArea" placeholder="这里是具体解释" maxlength="-1" v-model="form.explain_text"></textarea>
		</view>
		<view class="row">
			<view class="title">纠错依据</view>
			<textarea class="textArea" placeholder="这里是纠错依据" maxlength="-1" v-model="form.according_text"></textarea>
		</view>
		<view class="btn" @click.stop="submit">提交</view>
	</view>
</template>

<script>
import {
	httpTokenRequest
} from '@/utils/http.js';
export default {
	data() {
		return {
			form: {
				type: "",//	是	string	类型:1=问题库,2=准则与法条,3=优质问题
				wrong_text: "",//	是	string	出错点
				explain_text: "",//	是	string	解释
				according_text: "",//	是	string	依据
				record_id: "",//	是	string	无
			}
		};
	},
	methods: {
		isFlag() {
			const { wrong_text, explain_text, according_text } = this.form;
			const showToast = (message) => {
				this.$tools.showToast(message);
				return false;
			};
			if (!wrong_text) return showToast("请填写出错点");
			if (!explain_text) return showToast("请填写解释");
			if (!according_text) return showToast("请填写依据");
			return true;
		},
		submit() {
			if (!this.isFlag()) return;
			var data = this.form;
			httpTokenRequest({
				method: 'POST',
				url: this.$paths.look_errorpublish,
				params: data
			}).then(res => {
					if (res.code == 1) {
						this.$tools.showToast("提交成功");
						setTimeout(res => {
							uni.navigateBack({
								delta: 1
							})
						}, 1000)
					} else {
						this.$tools.showToast(res.msg);
					}
				})
				.catch(err => {
					console.log('错误回调', err);
				});
			this.$tools.showToast("提交成功");
		},
	},
	onLoad(e) {
		let { type, id } = e
		this.form.type = type;
		this.form.record_id = id;
	},
}
</script>

<style lang="scss">
.main {
	width: 100vw;

	background-color: #ffffff;
	padding: 30rpx;
	box-sizing: border-box;

	.row {
		padding: 26rpx 30rpx;

		.title {
			font-size: 32rpx;
			font-family: PingFang SC;
			font-weight: 400;
			line-height: 45rpx;
			color: #232424;
			opacity: 1;
		}

		.textArea {
			box-sizing: border-box;
			margin: 20rpx;
			padding: 20rpx;
			width: 100%;
			min-height: 150rpx;
			background-color: #F5F5F5;
		}
	}

	.btn {
		width: 507rpx;
		height: 75rpx;
		background: #3B8CF5;
		opacity: 1;
		border-radius: 51rpx;
		text-align: center;
		line-height: 75rpx;
		color: white;
		margin: 60rpx auto 0;
	}
}
</style>
